﻿using PLCS.Domain.Shared.PLCConfigs;

namespace PLCS.Domain.PLCConfigs;

/// <summary>
/// PLC 配置实体类
/// </summary>
public class PLCConfig : BaseEntity
{
    /// <summary>
    /// PLC编号
    /// </summary>
    public string PLCNo { get; init; }

    /// <summary>
    /// 名称
    /// </summary>
    public string PLCName { get; set; }

    /// <summary>
    /// 地址
    /// </summary>
    public string IPAddress { get; set; }

    /// <summary>
    /// 机架号
    /// </summary>
    public int Rack { get; set; }

    /// <summary>
    /// 槽号
    /// </summary>
    public int Slot { get; set; }

    /// <summary>
    /// DB地址
    /// </summary>
    public int DBNumber { get; set; }

    /// <summary>
    /// 长度
    /// </summary>
    public int Length { get; set; }

    /// <summary>
    ///  类型
    /// </summary>
    public PLCType Type { get; set; }

    /// <summary>
    /// 是否使用
    /// </summary>
    public YesNo IsUse { get; set; }

    public ICollection<PLCReadData>? PLCReadDatas { get; set; }

    public PLCConfig()
    {
    }

    public PLCConfig(string pLCNo, string pLCName, string iPAddress, int rack, int slot, int dBNumber, int length, PLCType type)
    {
        PLCNo = pLCNo;
        PLCName = pLCName;
        IPAddress = iPAddress;
        Rack = rack;
        Slot = slot;
        DBNumber = dBNumber;
        Length = length;
        Type = type;
        CreationTime = DateTime.Now;
    }
}